﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using System.Data.SqlClient;

using Padelcenter.Common;

namespace Padelcenter.DataAccess
{
    public class Zona_Select : DataAccessBase
    {
        public Zona_Select()
        {
            StoredProcedureName = StoredProcedure.Name.Zona_SELECT.ToString();
        }

        public DataSet Get()
        {
            DataSet ds;

            Zona_Select_Prm zona_Select_Prm = new Zona_Select_Prm(this.Zona);
            DataBaseHelper dbhelper = new DataBaseHelper(StoredProcedureName);
            ds = dbhelper.Run(base.ConnectionString, zona_Select_Prm.Parameters);

            return ds;
        }

        private Zona _zona;

        public Zona Zona
        {
            get { return _zona; }
            set { _zona = value; }
        }
    }

    public class Zona_Select_Prm
    {
        public Zona_Select_Prm(Zona zona)
        {
            this.Zona = zona;
            this.BuildParams();
        }

        private void BuildParams()
        {
            SqlParameter[] parameters = 
            {
                new SqlParameter( "@idZona"             , this.Zona.IdZona ),
                new SqlParameter( "@ConFiltroActivo"    , this.Zona.ConFiltroActivo),
                new SqlParameter( "@Activo"             , this.Zona.Activo)
            };

            this.Parameters = parameters;
        }

        private Zona _zona;
        private SqlParameter[] _parameters;

        public SqlParameter[] Parameters
        {
            get { return _parameters; }
            set { _parameters = value; }
        }

        public Zona Zona
        {
            get { return _zona; }
            set { _zona = value; }
        }
    }
}
